import axios from "axios";
import notify from "./error";

const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 3000,
})

service.interceptors.request.use(
  (config) => {
    return config
  }
)

service.interceptors.response.use(
  (response)=>{
    if(response.status == 200){
      const res = response.data
      if(res.code == 2000){
        notify('success', res.message)
        return res.data
      }

      if(res.code == 4000){
        return notify('error', res.message)
      }
    }
  }
)


export default service